{extend name="public/base"}

{block name="title"}
收银台
{/block}

{block name="style"}
{css href="/static/wechat/css/order.css" /}
{/block}

{block name="body"}
<div class="pageControl pay">
    <div class="msui_nav msui_navTop">
        <a class="msui_navTop-back" href="javascript:history.back();"><i class="micon-back"></i></a>
        <h1 class="msui_navTop-title">收银台</h1>
    </div>
    <div class="weui-top">
        <div class="msui_cell msui_cell-column mt10">
            <div class="msui_cell-item">
                <p class="fs11 cl-orange">¥{$data.money}</p>
            </div>
            <div class="msui_cell-item">
                <p class="fs08 cl-9999">充值单:{$data.order_sn}</p>
            </div>
        </div>
        <div class="weui-cells weui-cells_checkbox js-choose">
            <div class="msui_cells-title fs08 cl-6666">选择支付方式</div>
            <label class="weui-cell weui-check__label">
                <div class="weui-cell__hd">
                    <input type="checkbox" class="weui-check" data-pay-type="weixin" checked>
                    <i class="micon-check"></i>
                </div>
                <div class="weui-cell__bd">
                    <div class="msui_table">
                        <div class="msui_tabCell-img">
                            <img src="/static/wechat/images/payPhoto3.png">
                        </div>
                        <div class="msui_tabCell-content">
                            <p class="fs08 cl-3333">微信</p>
                        </div>
                    </div>
                </div>
                <div class="weui-cell__ft">
                    <p class="cl-3333 fs075">¥<span class="pay_price">{$data.money}</span></p>
                </div>
            </label>
        </div>
        <div class="msui_button">
            <div class="msui_button-hd">
                <p class="cl-3333 fs08">待支付:<span class="cl-orange pay_price">{$data.money}</span></p>
            </div>
            <div class="msui_button-bd">
                <input type="hidden" name="select_coupon" value="0">
                <a  id="payMoney" class="msui_button-content">确认支付</a>
            </div>
        </div>
    </div>
</div>
<!-- loading toast -->
<div id="loadingToast" style="display:none;">
    <div class="weui-mask_transparent"></div>
    <div class="weui-toast" style="opacity: 1; visibility: visible;">
        <i class="weui-loading weui-icon_toast"></i>
        <p class="weui-toast__content">获取支付数据</p>
    </div>
</div>
{/block}

{block name="javascript"}

<script>
    $(function () {
        var _is_submit_gift = 0;
        $("#payMoney").click(function () {
            var _this = $(this);
            _this.text('正在支付').css('background', '#ddd');
            var pay_type = $("input[type='checkbox']:checkbox").data('pay-type');
            if (pay_type == 'weixin') {
                $('#loadingToast').fadeIn(100);
                $.ajax({
                    type : 'POST',
                    url : '{:url("pay/index")}',
                    data : {
                        money : '{$data.money}',
                        type : 'recharge',
                        order_sn : '{$data.order_sn}'
                    },
                    //dataType : 'json',
                    success : function(msg) {
                        if(msg.code == 400) {
                            alert(msg.msg);
                            _this.text('确认支付').css('background', '#fc4208');
                            $('#loadingToast').fadeOut(100);
                            return false;
                        } else {
                            $("html").append(msg);
                            setTimeout(function() {
                                callpay();
                                $('#loadingToast').fadeOut(100);
                            },200);
                        }
                    }
                });
            }
        });
    });
</script>
{/block}